load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
load("//pkg/testutils:buildutil/buildutil.bzl", "disallowed_imports_test")

go_library(
    name = "diagnostics",
    srcs = [
        "diagnostics.go",
        "reporter.go",
        "update_checker.go",
    ],
    importpath = "github.com/cockroachdb/cockroach/pkg/server/diagnostics",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/base",
        "//pkg/build",
        "//pkg/config/zonepb",
        "//pkg/keys",
        "//pkg/kv",
        "//pkg/roachpb",
        "//pkg/server/diagnostics/diagnosticspb",
        "//pkg/server/status/statuspb",
        "//pkg/server/telemetry",
        "//pkg/settings",
        "//pkg/settings/cluster",
        "//pkg/sql",
        "//pkg/sql/catalog",
        "//pkg/sql/catalog/descbuilder",
        "//pkg/sql/catalog/descpb",
        "//pkg/sql/sem/tree",
        "//pkg/sql/sessiondata",
        "//pkg/util/cloudinfo",
        "//pkg/util/envutil",
        "//pkg/util/httputil",
        "//pkg/util/log",
        "//pkg/util/log/logcrash",
        "//pkg/util/protoutil",
        "//pkg/util/stop",
        "//pkg/util/syncutil",
        "//pkg/util/system",
        "//pkg/util/timeutil",
        "//pkg/util/uuid",
        "@com_github_cockroachdb_errors//:errors",
        "@com_github_mitchellh_reflectwalk//:reflectwalk",
        "@com_github_shirou_gopsutil_v3//cpu",
        "@com_github_shirou_gopsutil_v3//host",
        "@com_github_shirou_gopsutil_v3//load",
        "@com_github_shirou_gopsutil_v3//mem",
        "@org_golang_google_protobuf//proto",
    ],
)

go_test(
    name = "diagnostics_test",
    size = "medium",
    srcs = [
        "main_test.go",
        "reporter_test.go",
        "update_checker_test.go",
    ],
    embed = [":diagnostics"],
    deps = [
        "//pkg/base",
        "//pkg/build",
        "//pkg/security/securityassets",
        "//pkg/security/securitytest",
        "//pkg/server",
        "//pkg/testutils/diagutils",
        "//pkg/testutils/serverutils",
        "//pkg/util/cloudinfo",
        "//pkg/util/leaktest",
        "//pkg/util/log",
        "@com_github_mitchellh_reflectwalk//:reflectwalk",
        "@com_github_stretchr_testify//require",
    ],
)

disallowed_imports_test(
    "diagnostics",
    # TODO(#81378): This should be flipped to "true".
    disallow_cdeps = False,
)
